package cn.learn.util;

/**
 * @author huangyezhan
 * @version 1.0
 * @date 2021年02月25日22:40
 */
public class DateUtil {

    public static String secondToTime(long second) {
        long days = second / 86400; //日
        second = second % 86400;    //剩余秒数
        long hours = second / 3600; //时
        second = second % 3600;     //剩余秒数
        long minutes = second / 60; //分
        second = second % 60;       //秒
        if (days > 0) {
            return days + "天" + hours + "小时" + minutes + "分" + second + "秒";
        } else if (hours > 0) {
            return hours + "小时" + minutes + "分" + second + "秒";
        } else if (minutes > 0) {
            return minutes + "分" + second + "秒";
        } else {
            return second + "秒";
        }
    }

    public static void main(String[] args) {
        System.out.println(secondToTime(500L));
    }

}
